package com.jhz.speedy.common.base;

import android.content.Context;
import android.view.LayoutInflater;
import java.util.ArrayList;
import java.util.List;

/**
 * 普通的adapter
 * Created by JunHeZ on 2017/2/16.
 */

public abstract class IBaseAdapter<T> extends android.widget.BaseAdapter {
    protected Context mContext;
    protected LayoutInflater mInflater;
    protected List<T> mList;

    public IBaseAdapter(Context context, List<T> list){
        this.mContext = context;
        this.mInflater = LayoutInflater.from(context);
        updateList(list);
    }

    public void updateList(List<T> list){
        if(list == null)
            list = new ArrayList<>();

        mList = list;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

}
